<template>
<!-- <skeleton></skeleton> -->
    <div v-show="skeleton">
<van-skeleton title :row="13" />
    </div>
  <div v-show="!skeleton">
    <van-nav-bar title="分类" left-text="返回" left-arrow @click-left="() => { $router.push('/') }" fixed />
    <div style="height: 45px;"></div>
    <van-row>
      <van-col span="6">
        <van-sidebar v-model="active">
          <div v-for="item in categoriesApiData">
            <van-sidebar-item :title="item.cat_name" />
          </div>
        </van-sidebar>
      </van-col>
      <van-col span="18">
        <Search></Search>
        <div v-for="item  in categoriesApiData[active]?.children">
          {{ item.cat_name }}
          <router-link :to="{name:'goods',params:{query	:item.cat_name}}">
          <van-grid :column-num="4" >
  <van-grid-item  v-for="items in item.children":icon="items.cat_icon" :text="items.cat_name" />
</van-grid></router-link>
</div>
        <div>
          <router-link :to="{name:'detail',params:{goods_id:57427}}">
          <van-card v-for="item in goodsApiData" :price="item.goods_price" desc="描述信息" origin-price="100.00"
            :title="item.goods_name">
            <template #thumb>
              <img
                :src="item.goods_big_logo ? item.goods_big_logo : 'https://fastly.jsdelivr.net/npm/@vant/assets/ipad.jpeg'"
          lazy-render  alt="" style="width: 70px;height: 80px; margin-top: 10px;">
            </template>
            <template #num>
              <van-stepper v-model="value" theme="round" button-size="22" disable-input />

            </template>
          </van-card>
        </router-link>
        </div>


      </van-col>

    </van-row>
  </div>
  <van-submit-bar :price="99900" button-text="提交订单" @submit="onSubmit">
<van-icon name="balance-list-o" badge="99+" size="3rem" />

</van-submit-bar>

</template>

<script setup>
import Search from '@/components/Search .vue';
// import skeleton from '@/components/skeleton.vue';
import { ref } from 'vue';
import { categoriesApi } from '@/api/api';
const categoriesApiData = ref([])
categoriesApi().then(res => {
  console.log(res);
  categoriesApiData.value = res.data.message
})
let active = ref(0)
import { goodsApi } from '@/api/api';
// const sj = [
// '电视',
// '空调',
// '洗衣机',
// '冰箱',
// '圣诞狂欢',
// '冲锋衣',
// ]
const sjj=('空调')
const goodsApiData = ref([])
goodsApi(sjj).then(res => {
  console.log(res);
  goodsApiData.value = res.data.message.goods
})
import { useRouter } from 'vue-router';
const router=useRouter()
const onSubmit=()=>{
router.push('/')
}

const skeleton=ref(true)
setTimeout(() => {
    skeleton.value=false
}, 1000)
</script>

<style lang="scss" scoped></style>